#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "qmqtt.h"
#include <QNetWork.h>
#include <QSslSocket>
#include <QSslKey>
#include <QSslConfiguration>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QSslSocket ssl_socket;
    ssl_socket.setPrivateKey("D:/dev/esp8266-dev/client_cert/client.key");
    ssl_socket.setLocalCertificate("D:/dev/esp8266-dev/client_cert/client.crt");
    QSslConfiguration ssl_config;
    ssl_config.setCaCertificates(QSslCertificate::fromPath("D:/dev/esp8266-dev/client_cert/ca.crt"));

    ssl_config.setPrivateKey(ssl_socket.privateKey());

    ssl_config.setLocalCertificate(ssl_socket.localCertificate());
    QMQTT::Client *client = new QMQTT::Client("edgewell.eptglobal.com", 8883,ssl_config);
    client->setClientId("QTclientId123");
    client->setUsername("epttest");
    client->setPassword("Password1");

}

MainWindow::~MainWindow()
{
    delete ui;
}
